home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Softshoe
/
Lisa's Mac Parts
/
MouseWatcher
/
MouseWatcher.cp
next >
Wrap
Text File
|
2000-06-23
|
1KB
|
73 lines
// MouseWatcher.cp
#ifndef MouseWatcher_h
#include "MouseWatcher.h"
#endif
#ifndef ListLoop_h
#include "ListLoop.h"
#endif
#ifndef ListOf_h
#include "ListOf.h"
#endif
#ifndef MouseEvent_h
#include "MouseEvent.h"
#endif
MouseWatcher::MouseWatcher( bool startEnabled )
: Enableable( startEnabled ),
link( this )
{
if ( startEnabled )
BeEnabled();
}
ListOf< MouseWatcher >& MouseWatcher::TheList()
{
static ListOf<MouseWatcher> theList;
return theList;
}
void MouseWatcher::BeEnabled()
{
TheList().Add( link, afterEnd );
}
void MouseWatcher::BeDisabled()
{
TheList().Remove( link );
}
const RegionObject& MouseWatcher::MouseSleepRegion()
{
static RegionObject region( Rectangle::big );
region = Rectangle::big;
for ( ListLoop<MouseWatcher> watcher( TheList() );
watcher.Unfinished();
watcher++ )
region &= watcher->sleepRegion;
return region;
}
void MouseWatcher::Report( const MouseEvent& event )
{
for ( ListLoop<MouseWatcher> watcher( TheList() );
watcher.Unfinished();
watcher++ )
{
if ( watcher->sleepRegion.Contains( event.GlobalPoint() ) )
continue;
watcher->sleepRegion = Rectangle( event.GlobalPoint().h,
event.GlobalPoint().v,
event.GlobalPoint().h + 1,
event.GlobalPoint().v + 1 );
watcher->MouseMoved( event, watcher->sleepRegion );
Assert( watcher->sleepRegion.Contains( event.GlobalPoint() ) );
}
}